<?php
/**
 * @package WordPress
 * @subpackage Showcaser Theme
 */

//register settings
function showcaser_theme_settings_init(){
	register_setting( 'showcaser_theme_settings', 'showcaser_theme_settings' );
}

//menu
function showcaser_add_settings_page() {
add_menu_page( __( 'Showcaser' ), __( 'Showcaser' ), 'manage_options', 'showcaser-settings', 'showcaser_theme_settings_page');
}

add_action( 'admin_init', 'showcaser_theme_settings_init' );
add_action( 'admin_menu', 'showcaser_add_settings_page' );

//start settings page
function showcaser_theme_settings_page() {
global $slider_effects;
if ( ! isset( $_REQUEST['updated'] ) )
$_REQUEST['updated'] = false;
?>

<div class="wrap">
<div id="icon-options-general" class="icon32"></div>
<h2><?php _e( 'Showcaser 主题设置' ) ?></h2>


<?php if ( false !== $_REQUEST['updated'] ) : ?>
<div class="updated fade"><p><strong><?php _e( 'Options saved' ); ?></strong></p></div>
<?php endif; ?>
<form method="post" action="options.php">

<?php settings_fields( 'showcaser_theme_settings' ); ?>
<?php $options = get_option( 'showcaser_theme_settings' ); ?>

<table class="form-table">  

<tr valign="top">
<th scope="row"><?php _e( 'Favicon设置' ); ?></th>
<td>
<input id="showcaser_theme_settings[favicon]" class="regular-text" type="text" size="36" name="showcaser_theme_settings[favicon]" value="<?php esc_attr_e( $options['favicon'] ); ?>" />
<br />
<label class="description abouttxtdescription" for="showcaser_theme_settings[favicon]"><?php _e( '输入Favicon的URL地址.' ); ?></label>
</td>
</tr>

<tr valign="top">
<th scope="row"><?php _e( 'Logo设置' ); ?></th>
<td>
<input id="showcaser_theme_settings[logo]" class="regular-text" type="text" size="36" name="showcaser_theme_settings[logo]" value="<?php esc_attr_e( $options['logo'] ); ?>" />
<br />
<label class="description abouttxtdescription" for="showcaser_theme_settings[logo]"><?php _e( '输入LOGO的URL地址，如果空则默认显示网址名称（大号加粗）.' ); ?></label>
</td>
</tr>

<tr valign="top">
<th scope="row"><?php _e( 'Google Analytics（分析）' ); ?></th>
<td>
<textarea id="showcaser_theme_settings[analytics]" class="regular-text" name="showcaser_theme_settings[analytics]" rows="5" cols="45"><?php esc_attr_e( $options['analytics'] ); ?></textarea>
<br />
<label class="description" for="showcaser_theme_settings[analytics]"><?php _e( '添加Google Analytics（分析）代码，以便更清晰的了解你的网站.' ); ?></label>
</td>
</tr>

</table>
<p class="submit-changes">
<input type="submit" class="button-primary" value="<?php _e( 'Save Options' ); ?>" />
</p>
</form>
</div><!-- END wrap -->

<?php
}
//sanitize and validate
function showcaser_options_validate( $input ) {
	global $select_options, $radio_options;
	if ( ! isset( $input['option1'] ) )
		$input['option1'] = null;
	$input['option1'] = ( $input['option1'] == 1 ? 1 : 0 );
	$input['sometext'] = wp_filter_nohtml_kses( $input['sometext'] );
	if ( ! isset( $input['radioinput'] ) )
		$input['radioinput'] = null;
	if ( ! array_key_exists( $input['radioinput'], $radio_options ) )
		$input['radioinput'] = null;
	$input['sometextarea'] = wp_filter_post_kses( $input['sometextarea'] );

	return $input;
}

?>